/**
 * 
 */
package com.yangtao.prototype.system.dao;

import java.util.Date;

import org.hibernate.Criteria;
import org.hibernate.criterion.Order;
import org.springframework.stereotype.Repository;

import com.yangtao.framework.constant.Pagination;
import com.yangtao.framework.hibernate.BaseDao;
import com.yangtao.framework.hibernate.Selector;
import com.yangtao.prototype.system.entity.LogNote;

/**
 * @author 杨涛
 * 
 */
@Repository
public class LogNoteDAO extends BaseDao<LogNote> {

	public void addCustomCriterion(Criteria criteria) {
		criteria.addOrder(Order.desc("logInTime"));
	}

	/**
	 * @return the selector
	 */
	public Selector getSelector() {
		Selector selector = new Selector();
		selector.add(".user");
		return selector;
	}

	public Pagination findOnLineUser(Pagination page) {
		return findPage(page, "from LogNote ln where ln.state=?", "在线");
	}
	
	public void logOut(String id){
		String hql = "update LogNote set logOutTime=?,state=? where id=?";
		batchExecute(hql, new Date(), "正常退出", id);
	}
}
